<!-- 广告列表 -->
<table id="advertList" class="easyui-datagrid" title="{$currentpos}" data-options="
	fit:true,rownumbers:true,animate:true,fitColumns:true,
	url:'{:U('Pay/index')}',idField:'id',border:false,
	toolbar:advertToolbar,pagination:true,singleSelect:true,nowrap:false">
    <thead>
    <tr>
        <th data-options="field:'title',width:100,align:'center'">支付方式</th>
        <th data-options="field:'headsmall',width:80,align:'center',formatter:buildFace">支付图片</th>
        <th data-options="field:'account',width:100,align:'center'">支付账号</th>
        <th data-options="field:'person',width:100,align:'center'">持卡人(开户行)</th>
        <th data-options="field:'updatetime',width:100,align:'center'">修改时间</th>
        <th data-options="field:'id',width:100,align:'center',formatter:payOperateText">操作</th>
    </tr>
    </thead>
</table>

<!-- 添加 -->
<div id="payAddBox" class="easyui-dialog" title="添加广告"
     data-options="modal:true,closed:true,iconCls:'icon-add',buttons:[{text:'确定',iconCls:'icon-ok',handler:function(){$('#payAddForm').submit();}},{text:'取消',iconCls:'icon-cancel',handler:function(){$('#payAddBox').dialog('close');}}]"
     style="width: 730px; height: 380px;"></div>
<!-- 编辑 -->
<div id="payEditBox" class="easyui-dialog" title="编辑advert"
     data-options="modal:true,closed:true,iconCls:'icon-add',buttons:[{text:'确定',iconCls:'icon-ok',handler:function(){$('#payEditForm').submit();}},{text:'取消',iconCls:'icon-cancel',handler:function(){$('#payEditBox').dialog('close');}}]"
     style="width: 730px; height: 380px;"></div>
<script type="text/javascript">
    //工具栏
    var advertToolbar = [
        { text: '刷新', iconCls: 'icon-reload', handler: payRefreshList },
        { text: '添加', iconCls: 'icon-add', handler: payAdd },
    ];
    function buildFace(val,row,index){
        if(!val){
            return '<div style="height:60px;padding:3px;margin:auto;"></div>';
        }else{
            return '<div style="padding:3px;"><img src="'+val+'" height="60" style="padding:1px;border:1px solid #ccc;"></div>';
        }
    }
    //操作格式化
    function payOperateText(val, row, index){
        var btn = [];
        btn.push('<a href="javascript:void(0);" onclick="payEdit('+val+')">编辑</a>');
        return btn.join(' | ');
    }
    //刷新
    function payRefreshList(){
        $('#advertList').datagrid('reload');
    }
    //添加
    function payAdd(){
        var url = '{:U('Pay/add')}';
        $('#payAddBox').dialog({href:url});
        $('#payAddBox').dialog('open');
    }
    //advert编辑
    function payEdit(id){
        if(typeof(id) !== 'number'){
            $.messager.alert('提示信息', '请选择一条记录', 'error');
            return false;
        }
        var url = '{:U('Pay/edit')}';
        url += url.indexOf('?') != -1 ? '&id='+id : '?id='+id;
        $('#payEditBox').dialog({href:url});
        $('#payEditBox').dialog('open');
    }

</script>